import request from '@/utils/request'
import commom_path from '@/utils/cloudConstant'
const base_url=commom_path.LOGIN_PUBLIC_PATH;
export const getUsers = (params: any) =>
  request({
    url: '/users',
    method: 'get',
    params
  })

export const getUserInfo = () =>
  request({
    url: `${base_url}/info`,
    method: 'get'
  })

// @ts-ignore
export const getUserByName = (username: string) =>
  request({
    url: `/users/${username}`,
    method: 'get'
  })

export const updateUser = (username: string, data: any) =>
  request({
    url: `/users/${username}`,
    method: 'put',
    data
  })

export const deleteUser = (username: string) =>
  request({
    url: `/users/${username}`,
    method: 'delete'
  })

export const login = (data: any) =>
  request({
    url: `${base_url}/login`,
    method: 'post',
    data
  })

export const logout = (username:string) =>
  request({
    url: '/logout',
    method: 'get',
    params : {
        username
    }
  })

export const register = (data: any) =>
  request({
    url: '/users/register',
    method: 'post',
    data
  })
